// pages/messageDetail/messageDetail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    params: {
      name: '王思',
      sex: 1,
      recordId: 2,
      age: '14-20岁',
      peferralStatus: 'Confirmed',
      statusName: '待确认',
      city: '江苏省无锡市',
      phoneNumber: '12343532435',
      creatTime: '2020-03-23 12:30',
    },
    messageList: [{
      time: '2033-01-12 12:33',
      userName: '医生',
      isDoctor: true,
      message: '你好',
    },{
      userName: '陈好',
      isDoctor: false,
      message: '患者是否可以现在转院',
    },{
      time: '2033-01-12 12:36',
      userName: '医生',
      isDoctor: true,
      message: '可以的',
    },{
      time: '2033-01-12 12:33',
      userName: '医生',
      isDoctor: true,
      message: '你好',
    },{
      userName: '陈好',
      isDoctor: false,
      message: '患者是否可以现在转院',
    },{
      time: '2033-01-12 12:36',
      userName: '医生',
      isDoctor: true,
      message: '可以的',
    }],
    messageValue: undefined,
    scrollTop: 0,
  },

  onLoad(options) {
    // 默认滚动条再最下面
    let query = wx.createSelectorQuery().in(this)
    query.select('.message-list').boundingClientRect(res=>{
       this.setData({
          scrollTop:  res.height
        })
     })
    query.exec(res=>{})
  },

  onInputChange(event) {
    this.setData({
      messageValue: event.detail
    })
  },

  gotoDetailPage(e) {
    const { active = '1' } = this.data;
    const { currentTarget: { dataset: { recordId } } } = e;
    wx.navigateTo({
      url: `/pages/recordDetail/recordDetail?tabActive=${active}&recordId=${recordId}`,
    })
  },
  
  chooseImage() {
    wx.chooseMedia({
      count: 9,
      mediaType: ['image','video'],
      sourceType: ['album', 'camera'],
      maxDuration: 30,
      camera: 'back',
      success(res) {
        console.log(res.tempFiles)
      }
    })
  }

})